package com.xbongbong.saas.service.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.contactuser.pojo.dto.ContactUserDeleteBatchDTO;
import com.xbongbong.pro.contactuser.pojo.vo.ContactUserDeleteBatchVO;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.saas.model.ContactUserModel;
import com.xbongbong.saas.service.ContactUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/3/10 16:18
 * @since v1.0
 */
@Service("contactUserService")
public class ContactUserServiceImpl implements ContactUserService {

    private static final Logger LOG = LoggerFactory.getLogger(ContactUserServiceImpl.class);

    @Resource
    private ContactUserModel contactUserModel;

    @Override
    public ContactUserDeleteBatchVO deleteBatch(ContactUserDeleteBatchDTO contactUserDeleteBatchDTO) throws XbbException {
        ContactUserDeleteBatchVO contactUserDeleteBatchVO = new ContactUserDeleteBatchVO();
        try {
            List<Long> contactIdIn = contactUserDeleteBatchDTO.getContactIdIn();
            String corpid = contactUserDeleteBatchDTO.getCorpid();
            contactUserModel.deleteBatchByContactIdIn(contactIdIn, corpid);
        } catch (Exception e) {
            LOG.error("ContactUserServiceImpl.deteleBatch 执行出错：", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return contactUserDeleteBatchVO;
    }
}
